import java.io.*;
import java.util.*;

/**
 * Author: Evgeniy Krasko.
 * Date: 4/7/14
 */
public class Main {

    BufferedReader reader;
    PrintWriter writer;
    StringTokenizer st = new StringTokenizer("");


    private Main() throws IOException {
        reader = new BufferedReader(new FileReader("input.txt"));
        writer = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() throws IOException {
        int n = nextInt();
        int m = nextInt();
        int[] from = new int[m];
        int[] to = new int[m];
        for (int i = 0; i < m; ++i) {
            from[i] = nextInt() - 1;
            to[i] = nextInt() - 1;
        }

        ArrayList<ArrayList<Integer>> graph = Embedder.getEmbedding(n, from, to);

        writer.println(graph.size());

        for (ArrayList<Integer> list : graph) {
            for (int v : list) {
                writer.print((v + 1) + " ");
            }
            writer.println();
        }
        writer.close();
    }

    int nextInt() throws IOException {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(reader.readLine());
        }
        return Integer.parseInt(st.nextToken());
    }
}
